@extends('layouts.admin')
@section('content')
    @include('vendor.ueditor.assets')
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{{url('/admin/info')}}">首页</a>  &raquo; 文章管理
    </div>
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
	<div class="result_wrap">
        <div class="result_title">
            <h3>文章管理</h3>
            @if(count($errors)>0)
                <div class="mark">
                    @if(is_object($errors))
                        @foreach($errors->all() as $error)
                            <p>{{ $error }}</p>
                        @endforeach
                    @else
                        <p>{{ $errors }}</p>
                    @endif
                </div>
            @endif
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href="{{url('admin/article/create')}}"><i class="fa fa-plus"></i>添加文章</a>
                <a href="{{ url('admin/article') }}"><i class="fa fa-recycle"></i>全部文章</a>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
    
    <div class="result_wrap">
        <form action="{{ url('admin/article') }}" method="post">
            {{csrf_field()}}
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th width="120">分类：</th>
                        <td>
                            <select name="cate_id">
                                @foreach($data as $d)
                                    <option value="{{ $d->cate_id }}">{{ $d->_cate_name }}</option>
                                @endforeach
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>文章标题：</th>
                        <td>
                            <input type="text" class="lg" name="art_title">
                        </td>
                    </tr>
                    <tr>
                        <th>编辑：</th>
                        <td>
                            <input type="text" class="sm" name="art_editor">
                        </td>
                    </tr>
                    <tr>
                        <th>缩略图：</th>
                        <td>
                            <input type="text" size="50" name="art_thumb">
                            <div type="file" id="file_upload" name="file_upload"> </div>
                            <link rel="stylesheet" href="{{asset('Huploadify/Huploadify.css')}}">
                            <script src="{{ asset('Huploadify/jquery.Huploadify.js') }}"></script>

                            <script type="text/javascript">
                                $(function(){
                                    <?php $timestamp = time();?>
                                    $('#file_upload').Huploadify({
                                        auto:true,
                                        fileTypeExts:'*.jpg;*.png;*.exe',
                                        multi:true,
                                        formData:{
                                            'timestamp' : '<?php echo $timestamp; ?>',
                                            '_token' : '{{ csrf_token() }}'
                                        },
                                        buttonText:'选择图片',//上传按钮上的文字
                                        fileSizeLimit:9999,
                                        showUploadedPercent:true,  //是否实时显示上传的百分比，如20%
                                        showUploadedSize:true,
                                        removeTimeout:100,
                                        uploader:'{{ url('admin/upload') }}',
                                        onUploadStart:function(){
                                            //alert('开始上传');
                                        },
                                        onInit:function(){
                                            //alert('初始化');
                                        },
                                        onUploadComplete:function(file,data,response){
                                            //alert('上传完成');
                                            $('input[name=art_thumb]').val(data);
                                            $('#art_thumb_img').attr('src', '/' + data);
                                            //alert(data);
                                        },
                                        onDelete:function(file){
                                            console.log('删除的文件：'+file);
                                            console.log(file);
                                        }
                                    });
                                });
                            </script>

                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <img src="" alt="" id="art_thumb_img" style="max-width:350px; max-height:100px;">
                        </td>
                    </tr>
                    <tr>
                        <th>关键词：</th>
                        <td>
                            <input type="text" class="lg" name="art_tag">
                        </td>
                    </tr>
                    <tr>
                        <th>描述：</th>
                        <td>
                            <textarea name="art_description"></textarea>
                        </td>
                    </tr>

                    <tr>
                        <th>文章内容：</th>
                        <td>
                            <!-- 编辑器容器 -->
                            <script id="container"
                                    type="text/plain"
                                    name="art_content"
                                    style="width:800px;height:200px">
                            </script>

                        </td>
                    </tr>

                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container', {
            toolbars: [
                ['bold', 'italic', 'underline', 'strikethrough', 'blockquote', 'insertunorderedlist', 'insertorderedlist', 'justifyleft','justifycenter', 'justifyright',  'link', 'insertimage', 'fullscreen']
            ],
            elementPathEnabled: false,
            enableContextMenu: false,
            autoClearEmptyNode:true,
            wordCount:false,
            imagePopup:false,
            autotypeset:{ indent: true,imageBlockLine: 'center' }
        });

    </script>

@endsection